<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript" src="jquery/fancybox/js/fancybox/fancybox/jquery.min.js"></script>

<script>
		!window.jQuery && document.write('<script src="jquery/fancybox/jquery-1.4.3.min.js"><\/script>');
	</script>
	<script type="text/javascript" src="jquery/fancybox/js/fancybox/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
	<script type="text/javascript" src="jquery/fancybox/js/fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	<link rel="stylesheet" type="text/css" href="jquery/fancybox/js/fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
 	<link rel="stylesheet" href="jquery/fancybox/js/fancybox/style.css" />   
    
    
	<script type="text/javascript">
		$(document).ready(function() {
			/*
			*   Examples - images
			*/

		

			$("a#example2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

		

			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});

			/*
			*   Examples - various
			*/

			$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});

			$("#various2").fancybox();

			$("#various3").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});

			$("#various4").fancybox({
				'padding'			: 0,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
		});
	</script>




<style type="text/css">
<!--
#style {
	
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: none;
	border-right-style: solid;
	border-bottom-style: none;
	border-left-style: solid;
	border-top-color: #F96;
	border-right-color: #F96;
	border-bottom-color: #F96;
	border-left-color: #F96;
	background:white;
}
-->
</style>
</head>

<body>
<table id="style" width="540" align="center" >
<?php include("connect/dbcon.php");

 $sodong=3*4;
  $nhom=5;			// so trang trong 1 nhom trang
  
  if(!isset($_GET["tst"])) {				// kiem tra da co tong so trang chua
  $kq=mysql_query("select * from may order by Ngay DESC",$link);
  $tongsotrang=ceil(mysql_num_rows($kq)/$sodong);
  $tongsonhom=ceil($tongsotrang/$nhom);
  }
  else
  {
  $tongsotrang=intval($_GET["tst"]);
   $tongsonhom=ceil($tongsotrang/$nhom);
  }
  
  
  
  if (!isset($_GET["p"]))      // neu chua co tham so p
  { 
      if (!isset($_GET["n"]))		// neu chua co tham so n
	  {$p=1; $n=1; }			// nhom hien hanh
	  else
	  {$n=intval($_GET["n"]);
	   $p=$n*$nhom-$nhom+1;  }			// tinh trang dau tien cua nhom n
  
  }
  else
  {
  	$p=intval($_GET["p"]);
	$n=ceil($p/$nhom);
  }
  
  $x=($p-1)*$sodong;

 
 $s="select * from may order by Gia DESC limit ".$x.",".$sodong; 
		$kq=mysql_query($s,$link);
		while($dong=mysql_fetch_array($kq))
			{			
?>
  <tr>
    <td width="176" valign="top"><div align="center">
    <a id="example2" href="images/product/<?php echo $dong["UrlHinh"]; ?>">
    <img width="80" height="80" src="images/product/<?php echo $dong["UrlHinh"]; ?>" /></a><br />
    <?php echo $dong["TenMay"]; ?><br />
     <a href="index.php?ACT=chitiet&idMay=<?php echo $dong["idMay"]; ?>"><img src="images/intro/button_details.gif" width="74" height="17" /></a><br />
    Giá : <font color="#FF0000"><?php echo number_format($dong["Gia"]); ?></font> VND
    </div></td>
    
     <!-- cot thu 2 -->
     <?php
	 if ($dong=mysql_fetch_array($kq))
	 {
	 ?>
    <td width="176" valign="top"><div align="center">
    <a id="example2" href="images/product/<?php echo $dong["UrlHinh"]; ?>">
    <img width="80" height="80" src="images/product/<?php echo $dong["UrlHinh"]; ?>" /></a><br />
    <?php echo $dong["TenMay"]; ?><br />
     <a href="index.php?ACT=chitiet&idMay=<?php echo $dong["idMay"]; ?>"><img src="images/intro/button_details.gif" width="74" height="17" /></a><br />
    Giá : <font color="#FF0000"><?php echo number_format($dong["Gia"]); ?></font> VND
    </div></td>
    <?php }		 ?>

     <!-- cot thu 3 -->
       <?php
	 if ($dong=mysql_fetch_array($kq))          // kiem tra xem co du lieu ko thi do? vao cot.
	 {
	 ?>
    <td width="176" valign="top"><div align="center">
    <a id="example2" href="images/product/<?php echo $dong["UrlHinh"]; ?>">
    <img width="80" height="80" src="images/product/<?php echo $dong["UrlHinh"]; ?>" /></a><br />
    <?php echo $dong["TenMay"]; ?><br />
     <a href="index.php?ACT=chitiet&idMay=<?php echo $dong["idMay"]; ?>"><img src="images/intro/button_details.gif" width="74" height="17" /></a><br />
    Giá : <font color="#FF0000"><?php echo number_format($dong["Gia"]); ?></font> VND
    </div></td>
    <?php }	 ?>
      
    
      
      
  </tr>

<?php } ?>
</table>
<p align="center">
<?php if ($n>1) {
	$n1=$n-1;
?>
<a href="index.php?ACT=may&n=<?php echo $n1; ?>&tst=<?php echo $tongsotrang; ?>"><<</a>&nbsp;

<?php } ?>	
<?php
$dau=($n-1)*$nhom+1;			// $dau : trang dau tien cua nhom n.
if ($n<$tongsonhom)				// neu chua phai la nhom cuoi .
{$cuoi=$dau+$nhom-1;
}
else
{$cuoi=$tongsotrang;}			// nguoc lai thi chon luon tongsotrang
for($i=$dau;$i<=$cuoi;$i++) 		
{ if ($i==$p)
   { echo $i."&nbsp;";
   }
   else
   {
 ?>
 <a href="index.php?ACT=loai&p=<?php echo $i; ?>&tst=<?php echo $tongsotrang; ?>"><?php echo $i; ?></a>
<?php
   }
}
?>   
<?php if ($n<$tongsonhom) {
	$n2=$n+1;
?>
<a href="index.php?ACT=loai&n=<?php echo $n2; ?>&tst=<?php echo $tongsotrang; ?>">>></a>&nbsp;
<?php } ?>
</p>
</body>
</html>